// 这个文件约等于数据库
const overMinutes = 5 * 60 * 1000;

export const news = {
    baidu: {
        lastTime: '', // 最后修改时间
        list: [], // list内容
    },
};

export function getStorage(type) {
    const nowTime = new Date();
    if (!news[type] || !news[type].lastTime || !news[type].list.length || (nowTime.getTime() - news[type].lastTime.getTime() > overMinutes)) {
        return false;
    }

    return news[type].list;
}

export function setStorage(hotNews, type: string) {
    if (hotNews && hotNews.length) {
        news[type] = {
            lastTime: new Date(),
            list: hotNews,
        };
    }
}

